package node;

public class node {
    // 姓名
    public String name;
    // id
    public int id;
    // 年龄
    public int age;
    // next指针
    public node next;

    public node(String name, int id, int age) {
        this.name = name;
        this.id = id;
        this.age = age;
        this.next = null;
    }

    public node() {
        this.name = "";
        this.id = 0;
        this.age = 0;
        this.next = null;
    }

    // 重写toString方法
    @Override
    public String toString() {
        return "node [name=" + name + ", id=" + id + "age=" + age + "]";
    }

    // 重写equals方法
    @Override
    public boolean equals(Object obj) {
        node node = (node) obj;
        return this.id == node.id && this.name.equals(node.name) && this.age == node.age;
    }

    // 获取排序索引
    public int getIndex(boolean isId) {
        if (isId) {
            return this.id;
        } else {
            return this.age;
        }
    }
}